    /********************************************************/
    /*                                                      */
    /*                                                      */
    /*         Copyright (C), 1993  SEIKO EPSON Corp.       */
    /*         ALL RIGHTS RESERVED                          */
    /*                                                      */
    /*                                                      */
    /*  file name : fopen.c                                 */
    /*                                                      */
    /*  Revision history                                    */
    /*      93/12/17    first release       S.Akaiwa        */
    /*      97/3/17	modified	    T.Katahira	    */
    /*			change function declaration	    */
    /*					to the ANSI style   */
    /*                                                      */
    /********************************************************/

#ifdef      UNIX
#include    "stdio.h"
#include    "errno.h"
#else
#include    <stdio.h>
#include    <errno.h>
#include	<smcvals.h>
#include	<_mj_os.h>
#endif

FILE    *
fopen(const char * sFilNamP, const char * sOpnModP)

    /********************************************************/
    /*                                                      */
    /*  This is dummy function.                             */
    /*  The fopen function always returns NULL pointer.     */
    /*  "No such file or directory" is set to the errno.    */
    /*                                                      */
    /*      RETURN  NULL    ... Error                       */
    /*                                                      */
    /*  <ANSI>                                              */
    /*      The fopen function opens file.                  */
    /*                                                      */
    /*      RETURN  NULL    ... Error                       */
    /*              Others  ... Pointer to the stream of    */
    /*                          open file                   */
    /*                                                      */
    /********************************************************/

    /* const char    *sFilNamP   ; string of open file name */
    /* const char    *sOpnModP   ;      string of open mode */
{
    
	FILE *fp;
	int fd;

	if (strcmp(sOpnModP, "r")==0)
	{
		if ((fd=FileOpen((char*)sFilNamP,FILEMODE_READONLY))<0)
		{
			errno=ENOENT;
			return NULL;
		}
	}
	else if (strcmp(sOpnModP,"w")==0)
	{
		remove(sFilNamP);
		fd=FileOpen((char*)sFilNamP,FILEMODE_CREATEWRITE);
		FileClose(fd);
		fd=FileOpen((char*)sFilNamP,FILEMODE_WRITE);
	}
	else if (strcmp(sOpnModP,"a")==0)
	{
		if((fd=FileOpen((char*)sFilNamP,FILEMODE_APPEND))<0)
			return NULL;
	}
	else if (strcmp(sOpnModP,"r+")==0)
	{
		if ((fd=FileOpen((char*)sFilNamP,FILEMODE_READWRITE))<0)
		{
			errno=ENOENT;
			return NULL;
		}
	}
	else if (strcmp(sOpnModP,"w+")==0)
	{
		remove(sFilNamP);
		fd=FileOpen((char*)sFilNamP,FILEMODE_CREATEWRITE);
		FileClose(fd);
		fd=FileOpen((char*)sFilNamP,FILEMODE_WRITE);
		FileClose(fd);
		fd=FileOpen((char*)sFilNamP,FILEMODE_READWRITE);
	}
	else if (strcmp(sOpnModP, "a+")==0)
	{
		if ((fd=FileOpen((char*)sFilNamP,FILEMODE_READWRITE))<0)
		{
			errno=ENOENT;
			return NULL;
		}
		FileSeek(fd,0,FILESEEK_END);
	}
	else
		return fopen((char*)sFilNamP,"r");

	fp=malloc(sizeof(FILE));

	fp->_flg = _UGETN;
	fp->_buf = '\0';
	fp->_fd = fd;

	return fp;
}

